/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author itachiu
 */
@Entity
@Table(name = "owner")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Owner.findAll", query = "SELECT o FROM Owner o"),
    @NamedQuery(name = "Owner.findByPersonPersonId", query = "SELECT o FROM Owner o WHERE o.personPersonId = :personPersonId")})
public class Owner implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "PERSON_PERSON_ID")
    private Integer personPersonId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
    private List<Pet> petList;
    @JoinColumn(name = "PERSON_PERSON_ID", referencedColumnName = "PERSON_ID", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Person person;

    public Owner() {
    }

    public Owner(Integer personPersonId) {
        this.personPersonId = personPersonId;
    }

    public Integer getPersonPersonId() {
        return personPersonId;
    }

    public void setPersonPersonId(Integer personPersonId) {
        this.personPersonId = personPersonId;
    }

    @XmlTransient
    public List<Pet> getPetList() {
        return petList;
    }

    public void setPetList(List<Pet> petList) {
        this.petList = petList;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (personPersonId != null ? personPersonId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Owner)) {
            return false;
        }
        Owner other = (Owner) object;
        if ((this.personPersonId == null && other.personPersonId != null) || (this.personPersonId != null && !this.personPersonId.equals(other.personPersonId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Owner[ personPersonId=" + personPersonId + " ]";
    }
    
}
